package com.mes.cloud.web;

import com.mes.cloud.api.dto.request.position.EmployeeNoListRequest;
import com.mes.cloud.api.dto.request.position.SysPositionOrgAuthRequest;
import com.mes.cloud.api.dto.request.position.SysPositionOrganizationAuthRequest;
import com.mes.cloud.api.dto.response.position.SysPositionOrganizationAuthDto;
import com.mes.cloud.common.JsonResult;
import com.mes.cloud.service.SysPositionOrganizationAuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import javax.validation.Valid;

/**
 * @author xy
 * @version 2019-08-02 14:16:11
 * @email yuan.xue3@pactera.com
 */
@Api(tags = "岗位组织授权关联表", value = "岗位组织授权关联表接口")
@RestController
@RequestMapping(value = "/sysPositionOrganizationAuth")
public class SysPositionOrganizationAuthController  {

    private SysPositionOrganizationAuthService sysPositionOrganizationAuthService;

    @Autowired
    public SysPositionOrganizationAuthController(SysPositionOrganizationAuthService sysPositionOrganizationAuthService) {
        this.sysPositionOrganizationAuthService = sysPositionOrganizationAuthService;
    }

    /**
     * 功能: 岗位组织授权关联表查询所有
     *
     * @param sysPositionOrganizationAuthRequest
     * @return JsonResult<List<SysPositionOrganizationAuthDto>>
     */
    @ApiOperation(value = "根据岗位查询岗位组织授权", notes = "根据岗位查询岗位组织授权")
    @PostMapping(value = "/list")
    public JsonResult<List<SysPositionOrganizationAuthDto>> list(@RequestBody SysPositionOrganizationAuthRequest sysPositionOrganizationAuthRequest) {
        return sysPositionOrganizationAuthService.list(sysPositionOrganizationAuthRequest);
    }

    @ApiOperation(value = "岗位组织授权新增", notes = "岗位组织授权新增")
    @PostMapping(value = "/organizationAuth")
    public JsonResult organizationAuth(@Valid @RequestBody SysPositionOrgAuthRequest sysPositionOrgAuthRequest) {
        return sysPositionOrganizationAuthService.organizationAuth(sysPositionOrgAuthRequest);
    }

    @ApiOperation(value = "获取当前登录者组织", notes = "获取当前登录者组织")
    @PostMapping(value = "/getOrganizationIdList")
    public JsonResult<List<String>> getOrganizationIdList() {
        return sysPositionOrganizationAuthService.getOrganizationIdList();
    }

    @ApiOperation(value = "获取当前登录者所有岗位，授权组织的员工工号", notes = "获取当前登录者所有岗位，授权组织的员工工号")
    @PostMapping(value = "/getEmployeeNoList")
    public JsonResult<List<String>> getEmployeeNoList(@Valid @RequestBody EmployeeNoListRequest employeeNoListRequest) {
        return sysPositionOrganizationAuthService.getEmployeeNoList(employeeNoListRequest);
    }
}
